/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.util.ArrayList;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

/**
 *
 * @author Sacha MASSON
 */
public class GroupList extends JList implements ListSelectionListener {

    ArrayList<String> list;
    private DefaultListModel l1;
    private String g1, g2, g3;
    private ContactList cl;

    public GroupList(ContactList c) {
        cl = c;
        l1 = new DefaultListModel();
        g1 = "Family";
        g2 = "Friends";
        g3 = "Work";
        l1.addElement(g1);
        l1.addElement(g2);
        l1.addElement(g3);
        this.setModel(l1);
        this.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        this.addListSelectionListener(this);
    }

    public DefaultListModel getL1() {
        return l1;
    }

    public void setL1(DefaultListModel l1) {
        this.l1 = l1;
    }

    @Override
    public void valueChanged(ListSelectionEvent e) {
       
        cl.groupActive = ((GroupList) e.getSource()).getSelectedIndex();
        cl.groupList(((GroupList) e.getSource()).getSelectedIndex());
    }

}
